<?php

/*
 * To change this license header, choose License 
Headers in Project Properties.
 * To change this template file, choose Tools | 
Templates
 * and open the template in the editor.
 */

class OrderAction extends Action {
	

	//订单列表
	public function orderlist() {
		$o_order = M("orders");
		if (isset($_GET ['keyword'])) {
			$status = $this->_get('keyword');
			//var_dump($status);die;
			$list = $o_order->where('status="' . $status . '"')->select();
		}else{


			import("ORG.Util.Page");

			$count = $o_order->count();
			$listrow = 6;
			$page = new Page($count,$listrow);
			$show = $page->show();
			$list = $o_order->order('order_id')->limit($page->firstRow . "," . $page->listRows)->select();

		}
		$this->assign('lists', $list);
		$this->show = $show;
		$this->display();

	}
	//修改订单

	public function edit() {
		$o_order = M("orders");
		if (IS_GET) {
			$data = I('get.');
			$order = $o_order->where
			('order_id="' . $data['order_id'] . '"')->find();
			$this->assign('order',
			$order);
			$this->display();
		}
		if (IS_POST) {
			$datas = I('post.');
			$con = array('emp_id' => $datas['emp_id']);
			$cos = array('status' => 1);
			//var_dump($con);die;
			$result = $o_order->where('order_id="' . $datas['order_id'] . '"')->setField($con);
			if ($result) {			
				$o_order->where('order_id="' . $datas['order_id'] . '"')->setField($cos);
				$this->success('分配成功', U('Order/orderlist'));
			} else {
				$this->error('分配失败', U('Order/orderlist'));
			}
		}

	}

}
?>